package dk.hewison.client.domain;

import java.util.ArrayList;
import java.util.List;

/**
 * @author John Hewison
 * @author $LastChangedBy: john.hewison $:  $ $LastChangedDate: 2009-02-07 20:27:07 +0000 (Sat, 07 Feb 2009) $:
 * @version $Revision: 362 $:
 */
public class Slideshow {

    private boolean includeSubDirectories = true;
    private int timedelay = 4000;
    List<Photo> photos;

    Directory directory;

    public Slideshow(List<Photo> photos) {
        this.photos = photos;
    }

    public Slideshow(Directory directory) {
        this.directory = directory;
        photos = new ArrayList<Photo>();

        addDirectory(directory);

    }

    private void addDirectory(Directory directory) {
        photos.addAll(directory.getPhotos());

        //go through al sub directories and add all photos.
        if (includeSubDirectories) {
            List<Directory> subDirectories = directory.getSubDirectories();
            for (Directory subDirectory : subDirectories) {
                addDirectory(subDirectory);
            }
        }
    }

    public int getTimedelay() {
        return timedelay;
    }

    public void setTimedelay(int timedelay) {
        this.timedelay = timedelay;
    }

    public List<Photo> getPhotos() {
        return photos;
    }
}
